//
// Created by Jisam on 19/10/2024 19:41.
// Solution of  c
#include <bits/stdc++.h>

#define  int long long
#define  endl "\n"
#define  all(x) (x).begin(),(x).end()
#define  pb push_back
using namespace std;


signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n + 1, 0);
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    int ans = 0;
    sort(a.begin(), a.end());
    for(int i = 1; i < n; i ++){
        ans += sum;
        sum -= a[i];
    }
    cout << ans <<endl;
    return 0;
}